package com.hzsai.controller;

import com.alibaba.fastjson.JSON;
import com.hzsai.pojo.Order;
import com.hzsai.pojo.User;
import com.hzsai.service.OrderCustomerService;
import com.hzsai.utils.ResultMsg;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * hzsai 2019/8/18
 * usage:
 **/
@Api(tags = "mybatis-第4课")
@RestController
@RequestMapping("/order")
public class OrderCustomerController {

    @Autowired
    private OrderCustomerService service;

    @ApiOperation(value = "查询Order信息")
    @GetMapping("/find/{id}")
    ResultMsg findOrderById(@PathVariable Integer id) {
        Order order = service.findOrderById(id);
        System.out.println("【这个是】：" + order);
        return ResultMsg.success(order);
    }

    @ApiOperation(value = "根据Order信息来查询Order信息???")
    @PostMapping("/findUserByUserInfo/")
    ResultMsg findByUserInfo(@RequestBody User user) {
        System.out.println("User: " + user);
        return ResultMsg.success(service.findUserByUserInfo(user));
    }

    @ApiOperation(value = "更新User信息")
    @PostMapping("/updateUserInfo")
    ResultMsg updateUserInfo(@RequestBody User user) {
        System.out.println("UserInfo: " + user);
        return ResultMsg.success(service.updateUserInfo(user));
    }
}
